package com.topisv.tms.repository.stock.preInstorage;

import java.util.List;

import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;

import com.topisv.tms.entity.stock.instorage.pre.InstorageBillPre;

/**
 * 预约入库DAO
 *  Date          Author       Version       Description
 * ----------------------------------------------------------
 *  2014-7-3      CC            1.0           Create
 */
public interface InstorageBillPreDao extends PagingAndSortingRepository<InstorageBillPre, Long>, JpaSpecificationExecutor<InstorageBillPre> {
	@Query("select t from InstorageBillPre t left join t.preInBills p where p.inBillCode=?")
	InstorageBillPre findByInBillCode(String inBillCode);
	
	@Query("select t from InstorageBillPre t where billCode=?")
	InstorageBillPre findByBillCode(String billCode);
	
	@Query("select t from InstorageBillPre t where customerOrderNo=?")
    List<InstorageBillPre> findBycustomerOrderNo(String customerOrderNo);
	
	@Query("select t from InstorageBillPre t where customerCode=?1 and customerOrderNo=?2 and order_status < 2")
	InstorageBillPre findByCustomerCodeAndCustomerOrderNo(String customerCode,String customerOrderNo);
	
	@Query("select t from InstorageBillPre t where customerCode=?1 and customerOrderNo=?2 and orderStatus!=3")
	InstorageBillPre findByCustomerCodeAndCustomerOrderNo2(String customerCode,String customerOrderNo);
	
	@Query("select t from InstorageBillPre t where customerCode=?1 and customerOrderNo=?2 and order_status < 2")
	List<InstorageBillPre> findListByCustomerCodeAndCustomerOrderNo(String customerCode,String customerOrderNo);
}
